//
//  SignatureController.swift
//  ExpressDriver
//
//  Created by sheng on 2017/11/16.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit

class SignatureController: UIViewController {
    
    var paintView: PaintView!
    
    var saveBtn: UIButton!
    
    var cleanBtn: UIButton!
    
    let statusHeight = UIApplication.shared.statusBarFrame.height
    let scrrenHeight = UIScreen.main.bounds.height
    let scrrenWidth = UIScreen.main.bounds.width

    override func viewDidLoad() {
        super.viewDidLoad()
        setUI()
    }
    
    
    func setUI() {
        self.view.backgroundColor = UIColor.white
        let navigHeight = self.navigationController!.navigationBar.frame.height
        
        saveBtn = UIButton()
        let saveImage = UIImage(named:"save")?.withRenderingMode(.alwaysOriginal)
        saveBtn.setImage(saveImage, for:.normal)
        saveBtn.adjustsImageWhenHighlighted = false
        self.view.addSubview(saveBtn)
        saveBtn.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.view.snp.bottom).offset(-10)
            make.right.equalTo(-15)
            make.height.width.equalTo(25)
        }
        
        cleanBtn = UIButton()
        let cleanImage = UIImage(named:"eraser")?.withRenderingMode(.alwaysOriginal)
        cleanBtn.setImage(cleanImage, for:.normal)
        cleanBtn.adjustsImageWhenHighlighted = false
        cleanBtn.addTarget(self, action: #selector(cleanAll), for: .touchUpInside)
        self.view.addSubview(cleanBtn)
        cleanBtn.snp.makeConstraints { (make) in
            make.bottom.equalTo(saveBtn.snp.bottom)
            make.right.equalTo(saveBtn.snp.left).offset(-25)
            make.height.width.equalTo(25)
        }
        
        paintView = PaintView()
        paintView.backgroundColor = UIColor.white
        self.view.addSubview(paintView)
        paintView.snp.makeConstraints { (make) in
            make.top.equalTo(statusHeight + navigHeight)
            make.left.right.equalTo(0)
            make.bottom.equalTo(saveBtn.snp.top).offset(-10)
        }
        
    }

    
    
    func cleanAll(button : UIButton) {
        paintView.cleanAll()
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    

}
